package tv.geir.slackspace.event;

import javax.swing.event.EventListenerList;

import net.jini.core.event.EventRegistration;

import tv.geir.slackspace.matching.Template;

public class SpaceEventListenerList  {

	private EventListenerList listenerList;
	
	private long seqNumCounter = 1;
	
	public SpaceEventListenerList() {
		listenerList = new EventListenerList();
	}
	public void fireSpaceEvent( SpaceEvent evt ) {
		long seqNum = seqNumCounter++;
		
		Object[] listeners = listenerList.getListenerList();
	     // Process the listeners last to first, notifying
	     // those that are interested in this event
	     for (int i = listeners.length-2; i>=0; i-=2) {
	         if (listeners[i]== SpaceEventListener.class) {
	             ((SpaceEventListener)listeners[i+1]).spaceEventOccured( evt );
	         }
	     }
	}
	
	public EventRegistration addSpaceEventListener( SpaceEventListener listener , Template tmpl) {
		
		//EventRegistration er = new EventRegistration(
		listenerList.add( SpaceEventListener.class, listener );
		return null;
	}
	
	public void removeSpaceEventListener( EventRegistration er ) {
		//remove( SpaceEventListener.class,  );
	}
}
